package util

import (
	"bufio"
	"os"
)

func FileExists(file string) bool {
	_, err := os.Stat(file)
	return err == nil || os.IsExist(err)
}

func FileIsDir(file string) bool {
	f, err := os.Stat(file)
	if err != nil {
		return false
	}
	return f.IsDir()
}

//读取文件最后一行
func ReadFileLastLine(fileName string) (info string) {
	file, err := os.Open(fileName)
	if err != nil {
		return ""
	}
	defer file.Close()
	var lineText string
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		lineText = scanner.Text()
	}

	return string(lineText)
}
